﻿@model FMAPortalBase.Model.Page
@{
    ViewBag.Title = Model.Title;
    Layout = "~/Views/_shared/layout.cshtml";
    
    Dictionary<String, String> sectionList = (Dictionary<String, String>)ViewBag.sectionList;
    foreach (var item in sectionList)
    {
        try {
            DefineSection(item.Key, () =>
            {
                if (Model.Modules != null)
                {
                    var moduleList = Model.Modules.Where(x => x.Container.Equals(item.Key)).OrderBy(x => x.Order);
                    foreach (var module in moduleList)
                    {
                        Html.Partial(module.Path);
                    }
                }
            });
        }
        catch(Exception ex)
        {
           
            FMAPortalBase.FMAPortalParameters.LogManager.WriteLog(ex);
            DefineSection("body", () =>
            {
                var moduleList = Model.Modules.Where(x => x.Container.Equals(item.Key)).OrderBy(x => x.Order);
                foreach (var module in moduleList)
                {
                    Html.Partial(module.Path);
                }
            });
        }
    }
}